﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using com.qbengo.utility.nodepicker.entity;
namespace com.qbengo.utility.nodepicker.business
{
    /// <summary>
    /// EventTimetableBLL
    /// </summary>
    public partial class EventTimetableBLL
    {
        private readonly com.qbengo.utility.nodepicker.DAL.EventTimetableDao dal = new com.qbengo.utility.nodepicker.DAL.EventTimetableDao();
        public EventTimetableBLL()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int recid)
        {
            return dal.Exists(recid);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(com.qbengo.utility.nodepicker.entity.EventTimetable model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(com.qbengo.utility.nodepicker.entity.EventTimetable model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int recid)
        {

            return dal.Delete(recid);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string recidlist)
        {
            return dal.DeleteList(recidlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public com.qbengo.utility.nodepicker.entity.EventTimetable GetModel(int recid)
        {

            return dal.GetModel(recid);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public com.qbengo.utility.nodepicker.entity.EventTimetable GetModelByCache(int recid)
        {

            string CacheKey = "EventTimetableBLLModel-" + recid;
            object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(recid);
                    if (objModel != null)
                    {
                        int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (com.qbengo.utility.nodepicker.entity.EventTimetable)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<com.qbengo.utility.nodepicker.entity.EventTimetable> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<com.qbengo.utility.nodepicker.entity.EventTimetable> DataTableToList(DataTable dt)
        {
            List<com.qbengo.utility.nodepicker.entity.EventTimetable> modelList = new List<com.qbengo.utility.nodepicker.entity.EventTimetable>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                com.qbengo.utility.nodepicker.entity.EventTimetable model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new com.qbengo.utility.nodepicker.entity.EventTimetable();
                    if (dt.Rows[n]["recid"] != null && dt.Rows[n]["recid"].ToString() != "")
                    {
                        model.recid = int.Parse(dt.Rows[n]["recid"].ToString());
                    }
                    if (dt.Rows[n]["eventid"] != null && dt.Rows[n]["eventid"].ToString() != "")
                    {
                        model.eventid = int.Parse(dt.Rows[n]["eventid"].ToString());
                    }
                    if (dt.Rows[n]["from_utc"] != null && dt.Rows[n]["from_utc"].ToString() != "")
                    {
                        model.from_utc = DateTime.Parse(dt.Rows[n]["from_utc"].ToString());
                    }
                    if (dt.Rows[n]["to_utc"] != null && dt.Rows[n]["to_utc"].ToString() != "")
                    {
                        model.to_utc = DateTime.Parse(dt.Rows[n]["to_utc"].ToString());
                    }
                    if (dt.Rows[n]["activity_name"] != null && dt.Rows[n]["activity_name"].ToString() != "")
                    {
                        model.activity_name = dt.Rows[n]["activity_name"].ToString();
                    }
                    if (dt.Rows[n]["activity_location"] != null && dt.Rows[n]["activity_location"].ToString() != "")
                    {
                        model.activity_location = dt.Rows[n]["activity_location"].ToString();
                    }
                    if (dt.Rows[n]["activity_poi"] != null && dt.Rows[n]["activity_poi"].ToString() != "")
                    {
                        model.activity_poi = int.Parse(dt.Rows[n]["activity_poi"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

